from owl_admin.ext import db
from owl_ai.mapper.ai_model_mapper import ChatModelMapper
from owl_common.sqlalchemy.transaction import Transactional


class LLMModelService:

    @classmethod
    def find_llm_model_list(cls):
        model_list = ChatModelMapper.find_model_list()
        return {
            'rows': model_list,
            'total': len(model_list)
        }

    @classmethod
    @Transactional(db.session)
    def find_llm_model_by_id(cls, model_id: int):
        return ChatModelMapper.find_model_by_id(model_id)
